<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('模具试作通知单排版表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a href="http://192.168.2.234:18301/digiwin/kanban/view/report?viewlet=topprd%252Fcgl%252Fzh_CN%252Fcglr056_f01.cpt&ref_t=design&ref_c=300e2b33-49db-4c0e-b652-70bf7291b1e3"><a-button>跳转到报表链接</a-button></a>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <mold-trial-notice-typesetting-table-modal ref="modalForm" @ok="modalFormOk"/>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import MoldTrialNoticeTypesettingTableModal from './modules/MoldTrialNoticeTypesettingTableModal'
  import '@/assets/less/TableExpand.less'

  export default {
    name: "MoldTrialNoticeTypesettingTableList",
    mixins:[JeecgListMixin],
    components: {
      MoldTrialNoticeTypesettingTableModal
    },
    data () {
      return {
        description: '模具试作通知单排版表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'研发项目名称',
            align:"center",
            dataIndex: 'projectName'
          },
          {
            title:'客户',
            align:"center",
            dataIndex: 'customer'
          },
          {
            title:'PO订单号',
            align:"center",
            dataIndex: 'poOrder'
          },
          {
            title:'模号',
            align:"center",
            dataIndex: 'chtMoldNum'
          },
          {
            title:'品名',
            align:"center",
            dataIndex: 'productName'
          },
          {
            title:'试作材料/颜色',
            align:"center",
            dataIndex: 'trialMaterials'
          },
          {
            title:'系列',
            align:"center",
            dataIndex: 'series'
          },
          {
            title:'难度系数',
            align:"center",
            dataIndex: 'difficultyFactor'
          },
          {
            title:'模具穴数',
            align:"center",
            dataIndex: 'moldCavityNumber'
          },
          {
            title:'开模周期',
            align:"center",
            dataIndex: 'moldOpeningCycle'
          },
          {
            title:'单重',
            align:"center",
            dataIndex: 'singleWeight'
          },
          {
            title:'水口重',
            align:"center",
            dataIndex: 'nozzleWeight'
          },
          {
            title:'热流道形式',
            align:"center",
            dataIndex: 'hotRunnerType'
          },
          {
            title:'冷流道形式',
            align:"center",
            dataIndex: 'coldRunnerType'
          },
          {
            title:'原料用量',
            align:"center",
            dataIndex: 'rawMaterialDosage'
          },
          {
            title:'增润剂用量',
            align:"center",
            dataIndex: 'humectantAmount'
          },
          {
            title:'机台',
            align:"center",
            dataIndex: 'machineTable'
          },
          {
            title:'吨数',
            align:"center",
            dataIndex: 'tonnage'
          },
          {
            title:'试作数量（模）',
            align:"center",
            dataIndex: 'trialQuantity'
          },
          {
            title:'钳工担当',
            align:"center",
            dataIndex: 'fitterResponsible'
          },
          {
            title:'项目担当',
            align:"center",
            dataIndex: 'projectResponsibility'
          },
          {
            title:'模具完成时间',
            align:"center",
            dataIndex: 'moldCompletionTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'紧急度',
            align:"center",
            dataIndex: 'urgencyDegree'
          },
          {
            title:'计划试作时间',
            align:"center",
            dataIndex: 'planTrialTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'实际试作时间',
            align:"center",
            dataIndex: 'actualTrialTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'试作次数',
            align:"center",
            dataIndex: 'trialsNumber'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remark'
          },
          {
            title:'试作目的',
            align:"center",
            dataIndex: 'trialPurpose'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/ch/moldTrialNoticeTypesettingTable/list",
          delete: "/ch/moldTrialNoticeTypesettingTable/delete",
          deleteBatch: "/ch/moldTrialNoticeTypesettingTable/deleteBatch",
          exportXlsUrl: "/ch/moldTrialNoticeTypesettingTable/exportXls",
          importExcelUrl: "ch/moldTrialNoticeTypesettingTable/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
         fieldList.push({type:'string',value:'projectName',text:'研发项目名称',dictCode:''})
         fieldList.push({type:'string',value:'customer',text:'客户',dictCode:''})
         fieldList.push({type:'string',value:'poOrder',text:'PO订单号',dictCode:''})
         fieldList.push({type:'string',value:'chtMoldNum',text:'模号',dictCode:''})
         fieldList.push({type:'string',value:'productName',text:'品名',dictCode:''})
         fieldList.push({type:'string',value:'trialMaterials',text:'试作材料/颜色',dictCode:''})
         fieldList.push({type:'string',value:'series',text:'系列',dictCode:''})
         fieldList.push({type:'string',value:'difficultyFactor',text:'难度系数',dictCode:''})
         fieldList.push({type:'string',value:'moldCavityNumber',text:'模具穴数',dictCode:''})
         fieldList.push({type:'string',value:'moldOpeningCycle',text:'开模周期',dictCode:''})
         fieldList.push({type:'string',value:'singleWeight',text:'单重',dictCode:''})
         fieldList.push({type:'string',value:'nozzleWeight',text:'水口重',dictCode:''})
         fieldList.push({type:'string',value:'hotRunnerType',text:'热流道形式',dictCode:''})
         fieldList.push({type:'string',value:'coldRunnerType',text:'冷流道形式',dictCode:''})
         fieldList.push({type:'string',value:'rawMaterialDosage',text:'原料用量',dictCode:''})
         fieldList.push({type:'string',value:'humectantAmount',text:'增润剂用量',dictCode:''})
         fieldList.push({type:'string',value:'machineTable',text:'机台',dictCode:''})
         fieldList.push({type:'string',value:'tonnage',text:'吨数',dictCode:''})
         fieldList.push({type:'string',value:'trialQuantity',text:'试作数量（模）',dictCode:''})
         fieldList.push({type:'string',value:'fitterResponsible',text:'钳工担当',dictCode:''})
         fieldList.push({type:'string',value:'projectResponsibility',text:'项目担当',dictCode:''})
         fieldList.push({type:'date',value:'moldCompletionTime',text:'模具完成时间'})
         fieldList.push({type:'string',value:'urgencyDegree',text:'紧急度',dictCode:''})
         fieldList.push({type:'date',value:'planTrialTime',text:'计划试作时间'})
         fieldList.push({type:'date',value:'actualTrialTime',text:'实际试作时间'})
         fieldList.push({type:'string',value:'trialsNumber',text:'试作次数',dictCode:''})
         fieldList.push({type:'Text',value:'remark',text:'备注',dictCode:''})
         fieldList.push({type:'Text',value:'trialPurpose',text:'试作目的',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>